package com.edu.exam.entity.examination.paper;

import com.edu.exam.enums.examination.paper.TemplateStatus;
import com.edu.exam.enums.examination.paper.TemplateType;
import jakarta.persistence.*;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.hibernate.annotations.CreationTimestamp;
import org.hibernate.annotations.UpdateTimestamp;

import java.time.LocalDateTime;
import java.util.List;

/**
 * 计划模板实体类
 * 所属模块：E-01 考试执行模块
 * 对应数据库表：plan_template
 *
 * <p>考试计划模板，存储可复用的计划模板信息。
 * 用于标准化考试计划创建流程，提高计划制定效率和一致性。</p>
 *
 * @author System
 * @version 1.0.0
 */
@Entity
@Data
@EqualsAndHashCode(callSuper = false)
public class PlanTemplate {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    @Column(name = "template_name", length = 200, nullable = false)
    private String templateName;

    @Column(name = "template_type", length = 50, nullable = false)
    private String templateType;

    @Column(name = "template_status", length = 50, nullable = false)
    private String templateStatus;

    @Column(name = "template_content", columnDefinition = "TEXT")
    private String templateContent;

    @Column(name = "template_description", length = 500)
    private String templateDescription;

    @Column(name = "default_exam_duration")
    private Integer defaultExamDuration; // 默认考试时长（分钟）

    @Column(name = "required_resources", length = 1000)
    private String requiredResources; // 必需资源（JSON格式）

    @Column(name = "time_constraints", length = 1000)
    private String timeConstraints; // 时间约束（JSON格式）

    @Column(name = "capacity_constraints", length = 1000)
    private String capacityConstraints; // 容量约束（JSON格式）

    @Column(name = "approval_requirements", length = 1000)
    private String approvalRequirements; // 审批要求（JSON格式）

    @Column(name = "application_rules", length = 1000)
    private String applicationRules; // 应用规则（JSON格式）

    @Column(name = "version_number", nullable = false)
    private String versionNumber = "1.0";

    @Column(name = "is_system_template", nullable = false)
    private Boolean isSystemTemplate = false; // 是否为系统模板

    @Column(name = "is_public", nullable = false)
    private Boolean isPublic = false; // 是否公开

    @Column(name = "usage_count", nullable = false)
    private Integer usageCount = 0; // 使用次数

    @Column(name = "rating")
    private Double rating; // 模板评分（1-5）

    @Column(name = "rating_count")
    private Integer ratingCount = 0; // 评分次数

    @Column(name = "tags", length = 500)
    private String tags; // 标签（逗号分隔）

    @Column(name = "created_by", length = 64, nullable = false)
    private String createdBy;

    @CreationTimestamp
    @Column(name = "created_time", nullable = false, updatable = false)
    private LocalDateTime createdTime;

    @Column(name = "updated_by", length = 64)
    private String updatedBy;

    @UpdateTimestamp
    @Column(name = "updated_time")
    private LocalDateTime updatedTime;

    @Column(name = "last_used_by", length = 64)
    private String lastUsedBy;

    @Column(name = "last_used_time")
    private LocalDateTime lastUsedTime;

    @Version
    @Column(name = "version", nullable = false)
    private Integer version = 1;

}